package com.bxd.baodan.activity;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.gson.reflect.TypeToken;
import com.bxd.baodan.App;
import com.bxd.baodan.R;
import com.bxd.baodan.app.JsonApi;
import com.bxd.baodan.item.PlanerBean.PlanerBean_;
import com.bxd.baodan.util.GlideUtil;
import com.bxd.baodan.util.NetUtil;
import com.bxd.baodan.widget.StarBarView;
import com.tencent.TIMConversationType;
import com.tencent.qcloud.timchat.ui.ChatActivity;
import com.umeng.analytics.MobclickAgent;
import com.bxd.baodan.adapter.ViewHolder;

import java.lang.reflect.Type;
import java.util.List;

/**
 * Created by lizhichao on 17/8/29.
 */

public class PlanerActivity extends BaseListActivity<PlanerBean_> {
    @Override
    protected int getActivityLayout() {
        return R.layout.pull_refresh_layout_no_divider;
    }

    @Override
    protected void preDone() {
        setActionBarTitle("规划顾问团队");
        listView.addHeaderView(View.inflate(this, R.layout.planer_header, null));

        autoRefresh();
    }


    @Override
    protected Type getTypeToken() {
        return new TypeToken<List<PlanerBean_>>() {
        }.getType();
    }

    @Override
    protected int getItemLayout() {
        return R.layout.planer_item;
    }

    @Override
    protected void setNetUtil() {
        netUtil = new NetUtil(this, JsonApi.PLANNER_LISTS);
    }

    @Override
    protected void convert(ViewHolder holder, final PlanerBean_ item) {

        GlideUtil.loadCircle(PlanerActivity.this, item.avatar, ((ImageView) holder.getView(R.id.avatar)));
        ((TextView) holder.getView(R.id.nickname)).setText(item.nickname);
        ((TextView) holder.getView(R.id.serviceCount)).setText(item.serviceCount + "");
        ((TextView) holder.getView(R.id.sign)).setText(item.sign);

        ((StarBarView) holder.getView(R.id.star_bar)).setStarRating(item.star);



        holder.getView(R.id.chat).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (loginStatus()) {
                    MobclickAgent.onEvent(App.getContext(), "v6_1_3_SY_zxzx_zx");
                    ChatActivity.navToChat(PlanerActivity.this, item.id + "", true,item,TIMConversationType.C2C);
                }

            }
        });

        holder.getView(R.id.main).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (loginStatus()) {
                    MobclickAgent.onEvent(App.getContext(), "v6_1_3_SY_zxzx_zx");
                    ChatActivity.navToChat(PlanerActivity.this, item.id + "", true,item,TIMConversationType.C2C);
                }

            }
        });



    }

    @Override
    protected String getArrayStr(String json_data) {
        return "list";
    }

}
